package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.dao.CustosDAO;
import br.com.caelum.vraptor.dao.GenericDAO;
import br.com.caelum.vraptor.entidades.Custos;

@Controller
public class CustosController {
	
	@Inject
	private Result result;
	
	@Inject
	private GenericDAO<Custos> dao;
	
	public void add(){
		
	}
	
	public List<Custos> list(){
		
		return dao.find();
		
	}
	
	public void save(Custos custos){
		
		dao.save(custos);
		
		result.redirectTo(this).list();
	}
	
	public Custos edit(Integer codCustos){
		return dao.find(codCustos);
	}
	
	public void delete(int codCustos){
		Custos custos = new Custos();
		custos.setCodCustos(codCustos);
		dao.delete(custos);
		result.redirectTo(this).list();
	}
	
}
